<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商品管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="../css/style.css">
	<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>

</head>

<body class="hold-transition skin-red sidebar-mini" >
  <!-- .box-body -->
                
                    <div class="box-header with-border">
                        <h3 class="box-title">商品审核</h3>
                    </div>

                    <div class="box-body">

                        <!-- 数据表格 -->
                        <div class="table-box">

                            <!--工具栏-->
                            <div class="pull-left">
                                <div class="form-group form-inline">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-default" title="删除" ><i class="fa fa-trash-o"></i> 删除</button>
                                        <button type="button" class="btn btn-default" title="驳回" ><i class="fa fa-ban"></i> 驳回</button>
                                    </div>
                                </div>
                            </div>
                            <div class="box-tools pull-right">
                                <div class="has-feedback">
                                    商品名称：<input type="text" id="gname">
									<button class="btn btn-default" onclick="selectAll()">查询</button>
                                </div>
                            </div>
                            <!--工具栏/-->

			                  <!--数据列表-->
			                  <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
			                      <thead>
			                          <tr>
			                              <th class="" style="padding-right:0px">
			                                  <input id="selall" type="checkbox" class="icheckbox_square-blue">
			                              </th> 
										  <th class="sorting_asc">商品ID</th>
									      <th class="sorting">商品名称</th>
									      <th class="sorting">商品价格</th>
<!--									      <th class="sorting">一级分类</th>-->
<!--									      <th class="sorting">二级分类</th>-->
<!--									      <th class="sorting">三级分类</th>-->
									      <th class="sorting">状态</th>									     						
					                      <th class="text-center">操作</th>
			                          </tr>
			                      </thead>
			                      <tbody id="trs">
			                      </tbody>
			                  </table>
			                  <!--数据列表/-->                        

							 
                        </div>
                        <!-- 数据表格 /-->
                        
                        
                     </div>
                    <!-- /.box-body -->
        
</body>
</html>
<script>
	$(function (){
		selectAll();
	})

	function selectAll(){
	    var gname = $("#gname").val();
		$.ajax({
			url:"/goodsContrller/select",
			type:"post",
			data:{goodsName:gname},
			dataType:"json",
			async:false,
			success:function (rou){
				var set = rou.resout;
				var o = ""
				for (var i = 0; i < set.length; i++) {
					o += '<tr><td><input type="checkbox" value="'+set[i].id+'"></td>'
					o += '<td>'+set[i].id+'</td>'
					o += '<td>'+set[i].goodsName+'</td>'
					o += '<td>'+set[i].price+'</td>'
					if(set[i].auditStatus == ("0")){
						o += '<td><span>未审核</span></td>'
					}else if(set[i].auditStatus==("1")){
						o += '<td><span>审核通过</span></td>'
					}else if(set[i].auditStatus == ("2")){
						o += '<td><span>审核未通过</span></td>'
					}
					o += '<td className="text-center">'

					o += '<button type="button" class="btn btn-default" title="审核通过" onclick="Pass('+set[i].id+')"><i class="fa fa-check"></i>审核通过</button>'
					o += '<button type="button" class="btn btn-default" title="驳回" onclick="overrule('+set[i].id+')"><i class="fa fa-ban"></i>驳回</button> '
					o += '</td>'
					o += '</tr>'
				}
				$("#trs").html(o)
			},
			error:function (){
				alert("商家审核查询系统错误")
			}
		})
	}
	function Pass(id){
	    if(confirm("确定要审核通过吗?")){
            $.ajax({
                url:"/goodsContrller/pass",
                type:"post",
                dataType:"json",
                data:{id:id},
                async:false,
                success : function (set){
                    if(set.code == 1){
                        alert(set.massager);
                        window.location.reload();
                    }else {
                        alert(set.massager);
                        window.location.reload();
                    }
                },
                error:function (){
                    alert("审核通过操作系统错误")
                }
            })
        }else {
	        alert("取消成功");
            window.location.reload();
        }
    }
    function overrule(id){
	    if (confirm("确定要驳回吗?")){
            $.ajax({
                url:"/goodsContrller/overrule",
                type:"post",
                data:{id:id},
                dataType:"json",
                async:false,
                success:function (set){
                    if(set.code == 1){
                        alert(set.massager);
                        window.location.reload();
                    }else {
                        alert(set.massager);
                        window.location.reload();
                    }
                },
                error:function (){
                    alert("驳回系统错误")
                }
            })
        }else {
	        alert("取消成功")
            window.location.reload();
        }
    }
</script>
